﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace 刘颜红销售项目管理
{
    public partial class dlgConfig : Form
    {
        public dlgConfig()
        {
            InitializeComponent();
            this.DialogResult = DialogResult.Cancel;
        }

        private void btnBrowse_Click(object sender, EventArgs e)
        {
            using (OpenFileDialog dlg = new OpenFileDialog())
            {
                dlg.Filter = "MDB数据库文件|*.mdb";
                dlg.CheckFileExists = true;
                dlg.FileName = txtDBFileName.Text;
                if (dlg.ShowDialog(this) == DialogResult.OK)
                {
                    txtDBFileName.Text = dlg.FileName;
                }
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            string fileName = txtDBFileName.Text.Trim();
            if (System.IO.File.Exists( fileName) == false)
            {
                MessageBox.Show(this, "文件" + fileName + " 不存在!", "系统提示");
                return;
            }
            AppSettings.Default.DBFileName = fileName;
            AppSettings.Default.Save();
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void dlgConfig_Load(object sender, EventArgs e)
        {
            txtDBFileName.Text = AppSettings.Default.DBFileName;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}